import React from 'react';
import { View, Switch, Text } from 'react-native';
import styles from './styles';

class Flex extends React.Component {
  state = {
    aSwitch: true,
  }
  static navigationOptions = {
    title: 'Switch例子',
    text: '',
  };
  onSwitchChange = (event) => {
    this.setState({
      aSwitch: !this.state.aSwitch,
    });
  }
  render() {
    return (
      <View style={styles.container}>
        <View style={styles.rows}>
          <Text>开关1：</Text>
          <Switch style={{ marginLeft: 2 }}
            onValueChange={this.onSwitchChange}
            value={this.state.aSwitch}
          />
        </View>
        <View style={styles.rows}>
          <Text>开关2：</Text>
          <Switch style={{ marginLeft: 2 }}
            onValueChange={this.onSwitchChange}
            value={!this.state.aSwitch}
          />
        </View>
      </View>
    )
  }
}

export default Flex;
